<?php

namespace Modules\Api\Http\Controllers;

use HiCommon\Service\CommonService;
use HiCommon\Service\ShopCheckpointAppriseService;
use HiCommon\Service\ShopCheckpointService;
use Illuminate\Support\Facades\Request;
use Modules\Api\Service\ShopService;

class ShopCheckpointController extends BaseController
{
    /**
     * 获取已经开通的城市-以及所管辖的区
     */
    public function open_city_and_area()
    {
        try {
            return \HiCommon\Service\ShopService::api_open_city_and_area();
        } catch (\Exception $exception) {
            return hello_error('失败', [], $exception->getMessage());
        }
    }


    /**
     * 计算两个地理点的距离
     *
     * @return array|void
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function two_point_distance(){
        try {
            $arr_input = Request::input();
            return CommonService::api_location_distance($arr_input);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /**
     * 检测机构列表
     *
     * @return array|string
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function checkpoint_list()
    {
        try {
            $arr_search = Request::input();
            return ShopService::api_checkpoint_list($arr_search);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /**
     * 检测站-商家详情
     *
     * @return array|string
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function checkpoint_detail()
    {
        try {
            $n_id = intval(Request::input('id'));
            return ShopService::api_checkpoint_detail($n_id);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }

    }

    /**
     * 检测机构-规格参数价目表
     *
     * @return array|string
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function checkpoint_product_list()
    {
        try {
            $n_shop_id = intval(Request::input('shop_id'));
            $n_use_state = intval(Request::input('use_state'));
            return ShopService::api_checkpoint_products($n_shop_id,$n_use_state);
        } catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /**
     * 检测机构-近期预约日期列表-最多显示10条
     *
     * @return array|string
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function checkpoint_appointment_day_nearly()
    {
        try {
            $n_id = intval(Request::input('id'));
            return ShopCheckpointService::api_checkpoint_appointment_day_nearly($n_id);
        } catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }

    /**
     * 检测机构-车友评价列表
     *
     * @return array|string
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function checkpoint_apprise_list()
    {
        try {
            $n_shop_id = intval(Request::input('id'));
            return ShopCheckpointAppriseService::api_apprises_list_by_shopid($n_shop_id);
        }
        catch (\Exception $exception) {
            return hello_error('失败',[],$exception->getMessage());
        }
    }



}
